package com.bignerdranch.android.furnitureapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class AccountFragment extends BaseFragment implements View.OnClickListener {

    private TextView userName;
    private TextView userIntro;
    private RelativeLayout balanceLayout;
    private RelativeLayout recentHistory;
    private RelativeLayout myOrder;
    private RelativeLayout myCollection;

    public static AccountFragment newInstance() {
        return new AccountFragment();
    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_account;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(getLayoutResId(), container, false);
        initViews(rootView);
        return rootView;
    }

    private void initViews(View view) {
        userName = view.findViewById(R.id.user_name);
        userIntro = view.findViewById(R.id.user_describe);
        balanceLayout = view.findViewById(R.id.user_balance);
        recentHistory = view.findViewById(R.id.user_recent_history);
        myOrder = view.findViewById(R.id.order_click);
        myCollection = view.findViewById(R.id.collection_click);
        balanceLayout.setOnClickListener(this);
        recentHistory.setOnClickListener(this);
        myOrder.setOnClickListener(this);
        myCollection.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.user_balance:

                break;
            case R.id.user_recent_history:

                break;
            case R.id.order_click:
                startActivity(new Intent(getActivity(), ShowOrdersActivity.class));
                break;
            case R.id.collection_click:
                startActivity(new Intent(getActivity(), ShowCollectionActivity.class));
                break;
        }
    }
}
